package logic

import (
	"context"
	"medical/medicalrpc/medicalrpc"

	"medical/api/internal/svc"
	"medical/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewShopAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopAddLogic {
	return &ShopAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ShopAddLogic) ShopAdd(req *types.ShopAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.MedicalRpc.ShopAdd(l.ctx, &medicalrpc.ShopAddRequest{
		Num:    req.Num,
		Name:   req.Name,
		Type:   req.Type,
		Status: req.Status,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	} else {
		return &types.Response{
			Message: "添加成功",
			Code:    200,
			Data:    add,
		}, nil
	}

}
